package ctgu.java;

public class PreminumCaculator {
	public float rate(int age, String gender ,String marriage, int kid) {
		double count=0;
		float rate =0;
		assert age>=1 &&age<=99;
		assert "M".equals(gender) || "m".equals(gender) || "F".equals(gender) || "f".equals(gender); 
		assert "已婚".equals(marriage) || "未婚".equals(marriage);
		assert kid>=0 &&kid<=9;
		
		//年龄
		if (age>=20 &&age<=39) {
			count += 6;
		}
		else if (age>=40 &&age<=59) {
			count += 4;
		}
		else{
			count += 2;
		}
		
		//性别
		if ("M".equals(gender) || "m".equals(gender)) {
			count += 4;
		}
		if("F".equals(gender) || "f".equals(gender)) {
			count += 3;
		}
		
		//婚姻状况
		if("已婚".equals(marriage)) {
			count += 3;
		}
		if("未婚".equals(marriage)) {
			count += 5;
		}
			
		//抚养人数
		if(kid>=0 && kid<=6) {
			count = count -0.5*kid; 
		}
		else{
			count= count-3;
		}
		
		//计算点数判断保险率
		if (count >=10) {
			rate = 0.006f;
			}
		if (count<10) {
			rate = 0.001f;
			}
		return rate;
	}
}


